import { defineStore } from 'pinia'

interface INavList {
	title: string
	link: string
	icon?: string
	son?: INavList[]
}
export const useGlobalStore = defineStore({
	id: 'user',
	state: () => ({
		userInfo: {
			username: '',
			avatar: '',
			sid: '',//学号
			tid: '',//教师号
			rid: '',//管理员号
			role: '',//角色
			cid:'',//班级编号
			tphone:'',//教师电话
			semesterid:''//学期编号
		},
		NavList: [] as INavList[],
		IsLogin: false,
		PersonalLoginLink:""
	}),
	actions: {
		loginOut() {
			this.IsLogin = false
			this.userInfo = {
				username: '',
				avatar: '',
				sid: '',//学号
				tid: '',//教师号
				rid: '',//管理员号
				role: '',
				cid:'',
				tphone:'',
				semesterid:''
			}
			this.NavList = []
		},
	},
	persist: {
		enabled: true, //这个配置代表存储生效，而且是整个store都存储
	},
})
